// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2004-12-20

#ifndef __NET_MONITOR_H_COMMON_SVR_BASE__
#define __NET_MONITOR_H_COMMON_SVR_BASE__

#pragma once

#include <common/base/thread.h>

namespace JoyServer
{

#define JOY_ENABLE_NET_MONITOR

// tcp and udp traffic monitor.
class CJoyNetMonitor
{
public:
    class CMonitorData
    {
    public:
        CJoyCriticalSection m_lock;
        UINT64  m_transfer;
        UINT    m_operation;

        CMonitorData();

        void AddOperation(UINT trans);
    };

    class CProtoData
    {
    public:
        CMonitorData    m_recv;
        CMonitorData    m_send;
    };

    CProtoData  m_tcpData;
    CProtoData  m_udpData;

public:

    void AddSend(SOCKET s, UINT trans);
    void AddSendTo(SOCKET s, UINT trans);
    void AddRecv(SOCKET s, UINT trans);
    void AddRecvFrom(SOCKET s, UINT trans);
};

extern CJoyNetMonitor g_netMonitor;

} // namespace JoyServer

#endif  // __NET_MONITOR_H_COMMON_SVR_BASE__